package uit.ce.hungtrung;

import java.util.Timer;
import java.util.TimerTask;

import android.R.color;
import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageButton;

public class MenuActivity extends Activity {

	private ImageButton btnPlay;
	private ImageButton btnScore;
	private ImageButton btnExit;
	
	private Animation zoomOut;
	private Animation zoomIn;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
		setContentView(R.layout.activity_main);
		
		btnPlay = (ImageButton)findViewById(R.id.btnPlay);
		btnPlay.setBackgroundColor(color.transparent);
		btnScore = (ImageButton)findViewById(R.id.btnScore);
		btnScore.setBackgroundColor(color.transparent);
		btnExit = (ImageButton)findViewById(R.id.btnExit);
		btnExit.setBackgroundColor(color.transparent);
		
		zoomIn = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.zoom_in);
//		zoomIn.setAnimationListener(this);
//		zoomOut.setAnimationListener(this);
		zoomOut = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.zoom_out);
		
		btnPlay.setOnClickListener(new View.OnClickListener() {
			
			public void onClick(View v) {
				btnPlay.startAnimation(zoomIn);
				Timer tm = new Timer();
				tm.schedule(new TimerTask() {
					
					@Override
					public void run() {
						// TODO Auto-generated method stub
						Intent i = new Intent(MenuActivity.this, GameActivity.class);
						MenuActivity.this.startActivity(i);
						//cho nay báo lỗi
						btnPlay.clearAnimation();
					}
				}, 600);
			}
		});
		
		btnScore.setOnClickListener(new View.OnClickListener() {
			
			public void onClick(View v) {
				btnScore.startAnimation(zoomIn);
				Timer tm = new Timer();
				tm.schedule(new TimerTask() {
					
					@Override
					public void run() {
						// TODO Auto-generated method stub
						Intent i = new Intent(MenuActivity.this, ScoreActivity.class);
						MenuActivity.this.startActivity(i);
						btnScore.clearAnimation();
					}
				}, 600);
			}
		});
		
		btnExit.setOnClickListener(new View.OnClickListener() {
			
			public void onClick(View v) {
				btnExit.startAnimation(zoomIn);
				Timer tm = new Timer();
				tm.schedule(new TimerTask() {
					
					@Override
					public void run() {
						// TODO Auto-generated method stub
						btnExit.clearAnimation();
						MenuActivity.this.finish();
					}
				}, 600);
				
			}
		});
	}
}
